package com.itheima.map.mapdemo;

import java.util.HashMap;
import java.util.Map;

public class MyMap1 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        //map.put添加元素
        //如果要添加的键存在,则覆盖原先的值,并返回之前的值
        map.put("itheima001","小智");
        map.put("itheima002","小美");
        map.put("itheima003","小刚");
        map.put("itheima004","小刚");
        map.put("itheima004","小辣辣");


        System.out.println(map);

        //v remove(Object key)  根据键删除键值对元素
        map.remove("itheima001");
        System.out.println(map);

        //void clear()
//        map.clear();
//        System.out.println(map);

        //boolean containsKey(key);判断集合是否包含指定的键
        boolean ithiema1 = map.containsKey("ithiema");
        boolean ithiema2 = map.containsKey("itheima002");
        System.out.println("ithiema1 = " + ithiema1);
        System.out.println("ithiema2 = " + ithiema2);

        //boolean isEmpty()  判断map集合中是否为空


    }
}
